﻿using System;
using System.Runtime.CompilerServices;
using Core;
using Core.Base;
using Core.Extension;
using Global.Hall;
using UnityEngine;

namespace Logic.Hall.Mgr
{
    public class UIMgr : BaseUIMgr
    {
        private HallPanel hallPanel;


        public override void OnInit()
        {
            base.OnInit();
            Debug.Log("OnInit UIMgr");


            hallPanel.OnOpen();

            KKGL.UIEvent.RegHandler(EHall.SetHallPanelShowState, SetHallPanel, TokenSource.Token);
        }

        protected override void RegPanels()
        {
            hallPanel = RegPanel<HallPanel>();
        }

        private void SetHallPanel(ITuple obj)
        {
            bool isActivity = ((ValueTuple<bool>) obj).Item1;
            hallPanel.SetShowState(isActivity);
        }

        public override void OnDestroy()
        {
            Debug.Log("OnDestroy Hall UIMgr");
            hallPanel.OnClose();

            base.OnDestroy();
        }
    }
}